<template>
  <div>
    <!-- 吸附效果 -->
    <van-sticky :offset-top="44"> </van-sticky>

    <van-nav-bar title="联系我们" left-arrow @click-left="onClickLeft" />
    <van-cell v-for="(item, i) in cellList" is-link @click="cellClick(i)">
      <!-- 使用 title 插槽来自定义标题 -->
      <template #title>
        <span class="custom-title">{{ item.title }}</span>
        <span style="margin-left: 16px; font-size: 13px">{{
          item.subtitle
        }}</span>
      </template>
    </van-cell>
  </div>
</template>

<script setup>
import { copyText } from "@/utils";

//返回
const onClickLeft = () => history.back();

// cell数据源
const cellList = [
  {
    title: "电话",
    subtitle: "tel:4006088328",
  },
  {
    title: "电邮",
    subtitle: "info@cemarose.com",
  },
  {
    title: "微信客服3",
    subtitle: "cemarose3",
  },
  {
    title: "微信客服2",
    subtitle: "cemarose2",
  },
  {
    title: "微信客服1",
    subtitle: "cemarose1",
  },
  {
    title: "微博",
    subtitle: "cemarose",
  },
];

//cell点击事件
const cellClick = (index) => {
  const cellObj = cellList[index];

  if (index == 0) {
    window.location = cellObj.subtitle;
  } else if (index == 1) {
    window.open("mailto://");
  } else {
    copyText(cellObj.subtitle);
  }
};
</script>

<style lang="scss" scoped></style>
